<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">


<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:template match="/indici">
	<xsl:element name="indici">
		<xsl:apply-templates select="node()">
			
		</xsl:apply-templates>
	</xsl:element>
</xsl:template>


<xsl:template match="node() | @* | comment() | processing-instruction()">
<xsl:variable name="name" select="."/> 
  <xsl:if test="$name!='item'">
	  <xsl:copy>
	    <xsl:apply-templates select="@* | node()"/>
	  </xsl:copy>
  </xsl:if>
</xsl:template>

<xsl:template match="lang">
	<xsl:element name="lang">
	<xsl:apply-templates select="@* | comment() | processing-instruction()"/>
		<xsl:for-each select="item" >
			<xsl:sort data-type="number" select="@id" order="ascending" />
			<xsl:element name="item">
				<xsl:apply-templates select="@* | comment() | processing-instruction()"/>
					<xsl:for-each select="item" >
						<xsl:sort data-type="number" select="@id" order="ascending" />
						<xsl:element name="item">
							<xsl:apply-templates select="@* | comment() | processing-instruction()"/>
						</xsl:element>
					</xsl:for-each>
			</xsl:element>
		</xsl:for-each>
	</xsl:element>
</xsl:template>

</xsl:stylesheet>
